<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>

    // class的set get 赋值操作
    class Parent {
        constructor(name = '张三'){
            this.printName = name
        }
        get getnames(){
            return  '你今年多大了' + this.printName
        }
        set getnames(value){
            this.printName = value
        }
    }

    obj = new Parent()
    console.log(obj.getnames)
    // 赋值
    obj.getname = '我今年18岁了'
    console.log(obj.getname)


    // let buffer = new ArrayBuffer(10);
    // console.log(buffer.byteLength); // 10
    // // 分割已有数组缓冲区
    // buffer = new ArrayBuffer(10);
    // let buffer1 = buffer.slice(1, 3);
    // console.log(buffer1.byteLength); // 2

    var arr = [1,2,3,4,5,6,7,8,9]
    var pvg = arr.reduce(function(tmp,item,index) {
        if (index < arr.length - 1) {
            return tmp + item
        } else {
            return (tmp + item) / arr.length
        }
    })
    console.log(pvg)    
</script>

</html>